import { defineConfig } from "vite";
import { createVuePlugin } from "vite-plugin-vue2";
import { svgBuilder } from "./src/plugins/svgBuilder";
import { resolve } from "path";

export default defineConfig({
  plugins: [
    createVuePlugin(/*options*/),
    svgBuilder("./src/assets/icons/svg/"),
  ],
  resolve: {
    alias: {
      "~": resolve(__dirname, "./"),
      "@": resolve(__dirname, "src"),
    },
  },
  build: {
    rollupOptions: {
      input: {
        admin: resolve(__dirname, "entry/admin_index/index.html"),
        customer: resolve(__dirname, "entry/customer_index/index.html"),
        mobile: resolve(__dirname, "entry/mobile_index/index.html"),
      },
    },
  },
  server: {
    port: 8002,
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: '@import "@/assets/styles/resourses/variables.scss";',
      },
    },
  },
  postcss: {
    plugins: {
      autoprefixer: {},
      "postcss-pxtorem": {
        rootValue: 37.5, // 设计图px宽度/屏幕rem宽度(375/10 或750/20)
        unitPrecision: 5, // rem小数点
        propList: ["*"],
        selectorBlackList: [/^(?!\.m-)/], // 仅.m-开头的选择器转换rem, 单个属性忽略可以用 `Px` or `PX`
        replace: true,
        mediaQuery: false,
        minPixelValue: 1,
      },
    },
  },
});
